home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
dlx70bbs.zip
/
DLX70SRC.ZIP
/
FUNS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-02-14
|
40KB
|
1,006 lines
{$debug-}
{$line-}
{$include: 'types.int'}
{$include: 'globals.int'}
{$include: 'load.int'}
{$include: 'utils.int'}
{$include: 'database.int'}
{$include: 'funs.int'}
IMPLEMENTATION OF funs;
USES types,globals,load,utils,database;
{DLX Bulletin Board System V7.0
FREEWARE NOTICE
DLX V7.0 is placed in the public domain by its author, Richard Gillmann.
Anyone who wishes to may run the program, copy it, or modify it for
any purpose, including commercial gain.}
{***INTERFACE TO THE COM_PAX2 ASYNCHRONOUS COMMUNICATIONS PACKAGE***}
{$include: 'com_pax2.int'}
{***Interface to the PASASM assembler utilities package***}
{$include: 'pasasm.int'}
{$include: 'newasm.int'}
{***Interface to MS Pascal library***}
function freect(size:word) : word; EXTERN;
var
cancelled [EXTERN] : boolean;
bs_local [EXTERN] : byte;
procedure secs2time(secs : integer4; var tt : lstring);
var
s,m : integer4;
begin
copylst(ss[19],tt); {00:00:00}
if secs>0 then
[s:=secs mod 60;
secs:=secs div 60;
m:=secs mod 60;
secs:=secs div 60;
if secs<100 then
[tt[1]:=chr(ord('0')+ord(secs div 10));
tt[2]:=chr(ord('0')+ord(secs mod 10));
tt[4]:=chr(ord('0')+ord(m div 10));
tt[5]:=chr(ord('0')+ord(m mod 10));
tt[7]:=chr(ord('0')+ord(s div 10));
tt[8]:=chr(ord('0')+ord(s mod 10))]
else
[tt[1]:='9'; tt[2]:='9';
tt[4]:='5'; tt[5]:='9';
tt[7]:='5'; tt[8]:='9']];
end {secs2time};
procedure make12(var tt : lstring);
var
h : integer;
begin
if tt.len=8
then tt.len:=5
else return;
h:=10*(ord(tt[1])-ord('0')) + (ord(tt[2])-ord('0'));
if h=0 then
[tt[1]:='1'; tt[2]:='2';
concat(tt,' '); concat(tt,ss[24])] {AM}
else if h<12 then
[concat(tt,' '); concat(tt,ss[24])] {AM}
else if h=12 then
[concat(tt,' '); concat(tt,ss[25])] {PM}
else
[h:=h-12;
tt[1]:=chr(ord('0')+ord(h div 10));
tt[2]:=chr(ord('0')+ord(h mod 10));
concat(tt,' '); concat(tt,ss[25])]; {PM}
end {make12};
function match_pc(const toi : member_record) : integer;
var
pc,m,f,temp,i,j,wt1,wt2 : integer;
begin
{not relevant until logged in}
if not q[wx].logged_in then
[match_pc:=0; return];
{match perfectly to oneself}
if ivalue(toi.userid) = q[wx].userid then
[match_pc:=100; return];
{gender & orientation}
if q[wx].my.pref[1]=mn[3][1] {S} then
[if toi.pref[1]=mn[3][1] {S} then
[if q[wx].my.gender[1]=toi.gender[1]
then pc:=0 else pc:=100]
else if toi.pref[1]=mn[3][3] {G} then
pc:=0
else {B}
[if q[wx].my.gender[1]=toi.gender[1]
then pc:=0 else pc:=70]]
else if q[wx].my.pref[1]=mn[3][3] {G} then
[if toi.pref[1]=mn[3][1] {S} then
pc:=0
else if toi.pref[1]=mn[3][3] {G} then
[if q[wx].my.gender[1]=toi.gender[1]
then pc:=100 else pc:=0]
else {B}
[if q[wx].my.gender[1]=toi.gender[1]
then pc:=90 else pc:=0]]
else {b}
[if toi.pref[1]=mn[3][1] {S} then
[if q[wx].my.gender[1]=toi.gender[1]
then pc:=0 else pc:=70]
else if toi.pref[1]=mn[3][3] {G} then
[if q[wx].my.gender[1]=toi.gender[1]
then pc:=90 else pc:=0]
else {B}
pc:=100];
if pc=0 then [match_pc:=0; return];
{propinquity}
if q[wx].my.state=toi.state then
[if q[wx].my.city[1]<>toi.city[1] then pc:=pc-10]
else
pc:=pc-20;
{age};
m:=ivalue(q[wx].my.age); f:=ivalue(toi.age);
if q[wx].my.gender[1]=mn[2][2] {F} and then
toi.gender[1]=mn[2][1] {M} then
[temp:=m; m:=f; f:=temp];
if m<60 and then q[wx].my.gender[1]<>toi.gender[1]
then pc:=pc-5*abs(((3*m+14) div 4)-f)
else pc:=pc-5*abs(m-f);
{height}
if q[wx].my.gender[1]=mn[2][1] {M}
then m:=hvalue(q[wx].my.height)
else
[if metric
then m:=hvalue(q[wx].my.height)+13
else m:=hvalue(q[wx].my.height)+5];
if toi.gender[1]=mn[2][1] {M}
then f:=hvalue(toi.height)
else [if metric
then f:=hvalue(toi.height)+13
else f:=hvalue(toi.height)+5];
if metric
then pc:=pc-2*abs(m-f)
else pc:=pc-4*abs(m-f);
{weight}
wt1:=ivalue(q[wx].my.weight);
wt2:=ivalue(toi.weight);
if metric then {convert kg to lb}
[wt1:=(wt1*22) div 10;
wt2:=(wt2*22) div 10];
if wt1<100 then wt1:=250; {lying about weight}
if wt2<100 then wt2:=250;
temp:=(wt1+wt2-300) div 3; {lb}
if wt1>200 and then wt2>200 then {both fat}
temp:=temp div 2;
if temp>0 then pc:=pc-temp;
{weight difference}
if q[wx].my.gender[1]=mn[2][1] {M} and then
toi.gender[1]=mn[2][2] {F} and then
ivalue(q[wx].my.weight)<ivalue(toi.weight) then
temp:=ivalue(toi.weight)-ivalue(q[wx].my.weight)
else if q[wx].my.gender[1]=mn[2][2] {F} and then
toi.gender[1]=mn[2][1] {M} and then
ivalue(q[wx].my.weight)>ivalue(toi.weight) then
temp:=ivalue(q[wx].my.weight)-ivalue(toi.weight)
else temp:=0;
if metric
then pc:=pc-2*temp
else pc:=pc-temp;
{multiple choice questions}
for i:=1 to 2 do {based on just the first two questionnaires}
for j:=1 to number_of_answers do
if q[wx].my.mult_answer[i][j]<>' ' and then
q[wx].my.mult_answer[i][j]=toi.mult_answer[i][j] then
pc:=pc+1;
pc:=pc-5; {allow for random hits}
{limit range}
if pc<11 then
match_pc:=11
else if pc>100 then
match_pc:=100
else
match_pc:=pc;
end {match_pc};
type
jtype = (left,right,vari,vari_tr);
wtype = (my,your,xmy,xyour,usrlog);
ttype = (mins,hms);
var
arg : -1..99;
just : jtype;
whose : wtype;
plural : boolean;
time_f : ttype;
time_f2 : integer;
min_mem : integer4;
jlen : word;
value
min_mem := 1048576;
procedure init_fx;
begin
arg:=-1;
just:=vari;
whose:=my;
plural:=true;
time_f:=mins;
time_f2:=24;
jlen:=0;
end {init_fx};
function funx{col : integer; c1,c2 : char; var s : lstring} {boolean};
var
cap1,cap2,ok,special : boolean;
mrp : adr of member_record;
qrp : adr of q_record;
wrp : ads of window;
i,j,k : integer;
i4,j4 : integer4;
qst : questions;
p : para;
nl : word;
str : lstring(screen_cols+40);
mh : mailhead;
o2 : char;
kill : boolean;
label
skipcase;
procedure expand_macro(p : para);
var
xarg : -1..99;
xjust : jtype;
xwhose : wtype;
xplural : boolean;
xtime_f : ttype;
xtime_f2 : integer;
xmin_mem : integer4;
xjlen : word;
begin
{save state}
xarg:=arg; xjust:=just; xwhose:=whose; xplural:=plural;
xtime_f:=time_f; xtime_f2:=time_f2; xmin_mem:=min_mem; xjlen:=jlen;
macro_depth := macro_depth + 1;
{expand}
arg:=-1; just:=vari; jlen:=0;
copylst(p^.msg,str); delete(str,1,4);
eval(substitute(str)); stripx(str,s);
{restore state}
macro_depth := macro_depth - 1;
arg:=xarg; just:=xjust; whose:=xwhose; plural:=xplural;
time_f:=xtime_f; time_f2:=xtime_f2; min_mem:=xmin_mem; jlen:=xjlen;
end {expand_macro};
begin
kill:=false;
o2:=c2;
s.len:=0;
if c1>='A' and then c1<='Z'
then cap1:=true
else cap1:=false;
if c2>='A' and then c2<='Z'
then cap2:=true
else cap2:=false;
c1:=uc(c1); c2:=uc(c2);
wrp:=ads w^[wx]; qrp:=adr q[wx]; mrp:=adr q[wx].my;
case whose of
my : ;
your : [mrp:=adr q[wx].your;
i:=on_line(ivalue(mrp^.userid));
if i>=0 then mrp:=adr q[i].my];
xmy : if q[wx].index>=0 and then q[wx].index<=number_of_lines and then
w^[q[wx].index].active and then
w^[q[wx].index].state=going and then
q[q[wx].index].logged_in
then [mrp:=adr q[q[wx].index].my; qrp:= adr q[q[wx].index];
wrp:=ads w^[q[wx].index]]
else kill:=true;
xyour : if q[wx].index>=0 and then q[wx].index<=number_of_lines and then
w^[q[wx].index].active and then
w^[q[wx].index].state=going and then
q[q[wx].index].logged_in
then [mr